Complex database systems often need to access objects stored on remote databases. For example, a bank may need to transmit a financial transaction across several database servers in order to maintain integrity in their records. As another example, a shipping company may need to send package tracking information across several systems in order to make this data available to its customers.
A “cluster” is a system in which multiple database servers (“instances” or “nodes”) have access to the same database. A database to which the multiple nodes have access is referred to herein as a “cluster database.” The persistent storage that stores a cluster database is accessible by all nodes in the cluster. Typical database objects such as persistent tables, packages and procedures will be accessible from any node of the cluster database.
In a cluster database, one or more nodes may cache database information in a private area accessible only to that instance, e.g. in its volatile memory. For example, in a database cluster containing nodes N1, N2, and N3, a particular block of data may be cached on N1 and N3 in their respective volatile memories, but may not be cached on N2.
In order to access a block of information stored in the central database, a node may be granted a read lock, known as a“shared” or“S” lock; or a write lock, known as an“exclusive” or “X” lock. Several nodes may read the same block of information at once, and thus, several nodes may possess S locks for the same block of data. However, during a write operation, only the node which is modifying the block data may access the block. Thus, when one node possesses an X lock on a block of data, no other node may possess either an X lock or an S lock on that data block.
For each data block in the database, one node may be designated the Master node for that particular data block. The master node is responsible for coordinating access to the data block by granting and revoking X and S locks for the data block.
Oftentimes, one particular node will need to modify a certain data block repeatedly. This situation is common enough that current read-write protocols have been developed to optimize performance in this situation.
Thus, in existing systems, when a particular node, such as N1, wishes to modify a data block, the node will send a message to the appropriate Master node. The Master node is aware which other nodes in the system currently possess S locks on the data block, and the Master sends a message to these nodes to release their S locks. These nodes store local copies of the data block in their caches and release their S locks. These nodes then inform the Master that they have released their locks, and the Master then grants an X lock to N1.
Once in possession of the X lock, the node N1 modifies the data block. Because it is anticipated that N1 will modify the same data block in the near future, N1 does not release the X lock at this time.
Because N1 holds an X lock on the data block, other nodes who wish to read the data block cannot be granted an S lock. When another node requests an S lock from the Master node, the Master node redirects the requests to N1, who sends an updated copy of the data block to the requesting node to be stored in its local cache. N1 may continue to update the data block as long as it holds the X lock.
After N1 has received a predetermined number of requests for the data block, it is assumed that it is no longer efficient for N1 to possess the X lock. N1 will then release the X lock, allowing other nodes to obtain locks for the data block. For example, in one particular implementation, N1 may hold the X lock until it has received 10 requests for the data block. Once N1 receives the tenth request, it releases the X lock, and other nodes may obtain X or S locks for the data block.
Such a protocol has been optimized for a situation in which one node updates a particular data block repeatedly. However, in a situation where several nodes must read and write to the block frequently, this protocol may be inefficient. In particular, when one node holds an X lock, all read requests from other nodes in the system stall. Thus, it is desirable to implement an improved method for accessing data stored in a database, in a situation where many nodes require access to the same data block.